const mongoose = require('mongoose');
const moment = require('moment');
//创建结构对象
const UserSchema = new mongoose.Schema({
  //用户名
  username: {
    type: String,
    required: true // 设置该属性为必填项
  },
  //密码
  pwd: {
    type: String,
    required: true
  },
  //头像
  profile: {
    type: String,
  },
  //创建时间
  create_time: {
    type: String,
    //进行插入时, 会自动调用该函数
    default: () => moment().format('YYYY-MM-DD HH:mm:ss')
  }
});
//创建模型对象
const UserModel = mongoose.model('user', UserSchema);
//暴露对象
module.exports = UserModel;

